package projectManagement;

import javax.swing.*;

import java.awt.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class DeleteMemberConfirmationGUI extends JPanel implements ActionListener{
	String memberToDelete;
	JFrame f;
	public DeleteMemberConfirmationGUI(String member) {
		setPreferredSize(new Dimension(346, 193));
		setLayout(null);
		
		memberToDelete = member;
		JLabel lblMessage = new JLabel("CONFIRM DELETE");
		lblMessage.setHorizontalAlignment(SwingConstants.CENTER);
		lblMessage.setFont(new Font("Lucida Handwriting", Font.PLAIN, 24));
		lblMessage.setBounds(38, 34, 263, 71);
		add(lblMessage);
		
		JButton btnOk = new JButton("OK");
		btnOk.setBounds(38, 116, 118, 46);
		btnOk.putClientProperty("Quaqua.Button.style", "bevel");
		btnOk.addActionListener(this);
		add(btnOk);
		
		JButton btnCancel = new JButton("CANCEL");
		btnCancel.setBounds(179, 116, 118, 46);
		btnCancel.putClientProperty("Quaqua.Button.style", "bevel");
		btnCancel.addActionListener(this);
		add(btnCancel);
		
		f = new JFrame();
		f.add(this);
		f.setResizable(false);
		f.setVisible(true);
		f.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
		f.pack();
		f.setLocationRelativeTo(null);
	}

	@Override
	public void actionPerformed(ActionEvent btn) {
		String cmd = btn.getActionCommand();
		
		if(cmd.equalsIgnoreCase("OK")){
			ClientGUI.sendDeleteMemberToProject(memberToDelete);
			DeleteMemberPanel.updateList();
			f.setVisible(false);
		}
		
		if(cmd.equalsIgnoreCase("CANCEL")){
			f.setVisible(false);
		}
		
	}
}
